home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / mhis020.zip / CALLAVG.MH < prev    next >
Text File  |  1996-12-21  |  2KB  |  70 lines

  1. #ifndef __CALLAVG_MH
  2. #define __CALLAVG_MH
  3.  
  4. #ifndef __CALLSTAT_MH
  5. #include "callstat.mh"
  6. #endif
  7.  
  8. void stats_average (Ref struct _callstats: stats, long: min, long: max) {
  9.  
  10.   int: last_day, counter;
  11.   long: idx;
  12.   struct _callinfo: ci;
  13.  
  14.   stats_clear (stats);
  15.  
  16.   idx := min;
  17.   print (COL_YELLOW);
  18.   while ((idx <= max) AND call_read(idx, ci)) {
  19.     if (counter = 0) {
  20.       counter := 20;
  21.       print ((idx - min) * 100 / (max - min), "%\r");
  22.       };
  23.     counter := counter - 1;
  24.     if (ci.logoff.date.day <> last_day) {
  25.       stats.days := stats.days + 1;
  26.       last_day := ci.logoff.date.day;
  27.       };
  28.     if (meets_criteria (ci, callers.criteria)) {
  29.       stats_add (stats, ci);
  30.       };
  31.     idx := idx + 1;
  32.     if (kbhit ()) {
  33.       getch ();
  34.       print (COL_WHITE, "Aborted\n");
  35.       return;
  36.       };
  37.     };
  38.   print (COL_WHITE, "Done\n");
  39.   }
  40.  
  41. #define STATS_TITLE_WIDTH 12
  42. #define STATS_DATA_WIDTH  14
  43.  
  44. void stats_show_data (string: title, string: data) {
  45.   if (sys.current_col + STATS_TITLE_WIDTH + STATS_DATA_WIDTH > usr.width) {
  46.     print ('\n');
  47.     };
  48.   print (COL_CYAN,     strpadleft (title + ": ", STATS_TITLE_WIDTH,' '),
  49.          COL_LMAGENTA, strpad (data, STATS_DATA_WIDTH, ' '));
  50.   }
  51.  
  52. string stats_value (long: value, long: fact) {
  53.   return (division_result (value, fact, 2));
  54.   }
  55.  
  56. void stats_show (struct _callstats: s, long: fact) {
  57.   stats_show_data ("Calls", stats_value (s.calls, fact));
  58.   stats_show_data ("Time", seconds_to_string (s.time / fact));
  59.   stats_show_data ("Files up", stats_value (s.filesup, fact));
  60.   stats_show_data ("Files down", stats_value (s.filesdn, fact));
  61.   stats_show_data ("Msg read", stats_value (s.read, fact));
  62.   stats_show_data ("Msg posted", stats_value (s.posted, fact));
  63.   stats_show_data ("Kb up", stats_value (s.kbup, fact));
  64.   stats_show_data ("Kb down", stats_value (s.kbdn, fact));
  65.   stats_show_data ("Pages", stats_value (s.paged, fact));
  66.   }
  67.  
  68. #endif
  69.  
  70.